// 模拟 web端的requestAnimationFrame
// lastFrameTime为上次更新时间
var lastFrameTime = 0;
var doAnimationFrame = function (callback) {
  //当前毫秒数
  var currTime = new Date().getTime();
  var timeToCall = Math.max(0, 100 - (currTime - lastFrameTime));
  // console.log('timeToCall',timeToCall)
  var id = setTimeout(() => {
    callback();

  }, timeToCall);

  lastFrameTime = currTime + timeToCall;
  return id;
};
// 模拟 cancelAnimationFrame
var abortAnimationFrame = function (id) {
  clearTimeout(id)
}
module.exports = { doAnimationFrame, abortAnimationFrame }



